<template>
  <div :class="{'hidden':hidden}" class="pagination-container">
    <el-pagination
      :background="background"
      :current-page.sync="currentPage"
      :page-size.sync="pageSize"
      :layout="layout"
      :page-sizes="pageSizes"
      :total="total"
      v-bind="$attrs"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    ></el-pagination>
  </div>
</template>

<script>
import { scrollTo } from '@/utils/scroll-to';

export default {
  name: 'Pagination',
  props: {
    total: {
      required: true,
      type: Number
    },
    page: {
      type: Number,
      default: 0
    },
    limit: {
      type: Number,
      default: 20
    },
    pageSizes: {
      type: Array,
      default() {
        return [10, 20, 30]
      }
    },
    layout: {
      type: String,
      default: 'total, sizes, prev, pager, next'
    },
    background: {
      type: Boolean,
      default: true
    },
	background_Color: {
	  String: Boolean,
	  default: "blue"
	},
    autoScroll: {
      type: Boolean,
      default: false
    },
    hidden: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    currentPage: {
      get() {
        return this.page;
      },
      set(val) {
        this.$emit('update:page', val);
      }
    },
    pageSize: {
      get() {
        return this.limit;
      },
      set(val) {
        this.$emit('update:limit', val);
      }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.$emit('pagination', { page: this.currentPage, limit: val });
      if (this.autoScroll) {
        scrollTo(0, 800);
      }
    },
    handleCurrentChange(val) {
      this.$emit('pagination', { page: val, limit: this.pageSize });
      if (this.autoScroll) {
        scrollTo(0, 800);
      }
    }
  }
}
</script>

<style lang="scss" scoped>

.pagination-container {
  background: #fff;
  padding: 10px 0 0 16px;
}
.pagination-container.hidden {
  display: none;
}

::v-deep .el-select .el-input.is-focus .el-input__inner,el-pagination__size.el-input__inner:hover,el-select.el-input__inner:focus{
    border-color: #0082F0;
}
::v-deep el-pager li.active,.el-pager li:hover,el-pagination button:hover{
    color: #0082F0;
}
::v-deep el-select-dropdown__item.selected{
    color:#0082F0;
    font-weight: 700;
}
//修改鼠标滑过的颜色
::v-deep .el-pagination.is-background .el-pager li:hover {
    　　color: #0082F0;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled):hover {
    　　color: #0082F0 ;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
    color: #0082F0;
}

::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #0082F0 !important;
    color: #FFF;
}

::v-deep .el-pagination span:not([class*=suffix]) {
    display: inline-block;
    font-size: 13px;
    min-width: 50px;
    height: 28px;
    line-height: 28px;
    vertical-align: top;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

</style>
